package com.suarte.webapp.action;

import com.suarte.core.service.ContactManager;
import java.io.Serializable;
import java.util.List;

/**
 * @date   Dec 20, 2010
 * @author Ggutierrez
 */
public class ContactList extends BasePage implements Serializable {

    private ContactManager contactManager;
    private List contacts;
    private String firstName;
    private String lastName;

    public void setContactManager(ContactManager contactManager) {
        this.contactManager = contactManager;
    }

    public ContactList() {
        setSortColumn("id"); // sets the default sort column
    }

    public String execute() {
        contacts = sort(contactManager.findByNames(firstName, lastName));
        return "list";
    }

    public List getContacts() {
        contacts = sort(contactManager.findByNames(firstName, lastName));
        if (contacts != null) {
            return sort(contacts);
        } else {
            return contacts;
        }
    }

    public void setContacts(List contacts) {
        this.contacts = contacts;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }
}
